<?php
include_once 'inc/config.inc.php';
include "inc/mysql.inc.php";
?>

		<?php include"include/header.php" ?>		
			

			

			<div id="content" class="span10">
						
			<ul class="breadcrumb">
				<li>
					<i class="icon-home"></i>
					<a href="index.html">Home</a> 
					<i class="icon-angle-right"></i>
				</li>
				<li><a href="widgets.php">学生信息管理</a>
                    <i class="icon-angle-right"></i>
                    <a href="#">学生信息修改</a>
                </li>
			</ul>

<?php
$link = connect();
$id1 = $_GET['id'];

$sql3 = "select * from student where sid='$id1' ";
$rs3=execute($link,$sql3);
$row3=mysqli_fetch_assoc($rs3);

?>             
                <h2>请输入修改信息：</h2>
                <form  method="post">
                    学号：<?php echo $row3['sid']?><br>
                    姓名：<?php echo $row3['name']?><br>
                    年龄：<?php echo $row3['age']?><br>
                    专业：<?php echo $row3['professional']?><br>
                    联系方式：<input type="text" name="phone" value=<?php echo $row3['phone'] ?>><br>
                    楼栋号：<select name="ldh" style="width:100px;color:white;background-color: #4bb1cf" >
                        <option select="selected"><?php echo $row3['ldh']?></option>
                        <option value="东一">东一</option>
                        <option value="东二">东二</option>
                        <option value="东三">东三</option>
                        <option value="东四">东四</option>
                    </select><br>
                    宿舍号：<input type="text" name="ssh" value=<?php echo $row3['ssh'] ?>><br>

                    <input type="submit" name="sub" value="保存修改">
                </form>
	

        <?php include"include/footer.php"?>



                <?php

                if(!empty($_POST["sub"]))
                {

                    if(empty($_POST['phone'])||empty($_POST['ldh'])||empty($_POST['ssh']))
                            echo "请将修改信息填写完整";

                    else {
                                                                                                                       
                            $sql4 = "update student set phone={$_POST['phone']},ssh={$_POST['ssh']},ldh='{$_POST['ldh']}' where sid={$id1} ";
                            $link = connect();
                            $rs4=execute($link,$sql4); 
                           	if($rs4==1){

                           		$sql5 = "select * from student where sid={$id1}";
                           		$rs5=execute($link,$sql5);
                                $row5=mysqli_fetch_assoc($rs5);
                            
                            ?>
                            
                            <h3>学生信息修改成功</h3>
                            <?php }  ?>
                            <table width="800" border="2">
                                <tr>
                                    <th>学号</th>
                                    <th>姓名</th>
                                    <th>年龄</th>
                                    <th>专业</th>
                                    <th>联系方式</th>
                                    <th>楼栋号</th>
                                    <th>宿舍号</th>
                                </tr>

                                <tr>
                                    <td align="center"><?php echo $row3['sid'] ?></td>
                                    <td align="center"><?php echo $row3['name'] ?></td>
                                    <td align="center"><?php echo $row3['age'] ?></td>
                                    <td align="center"><?php echo $row3['professional'] ?></td>
                                    <td align="center"><?php echo $row5['phone'] ?></td>
                                    <td align="center"><?php echo $row5['ldh']?></td>
                                    <td align="center"><?php echo $row5['ssh'] ?></td>

                                </tr>
                            </table>
                            <?php
                        }

                }

                ?>
	
</body>
</html>
